import { Flex } from "antd";
import MenuItem from "./MenuItem";
import { useEffect, useState } from "react";
import type { Menu } from "@/apis/auth/type";
import { useSelector } from "react-redux";

export default function MenuList() {

    let stateMenus=useSelector((state:any)=>state.menus);
    console.log(stateMenus);
    



    const [menus, setMenus]=useState<Menu[]>([]);
    useEffect(()=>{
       
        setMenus(stateMenus);
        //setMenus(sessionStorage.getItem("menus") ? JSON.parse(sessionStorage.getItem("menus")!) :[]);
    },[])

  
    return (
        <Flex vertical>
            {
                menus.map((item) => (
                    <MenuItem key={item.id}  menu={item} />
                ))
            }
           
        </Flex>

    );
}